package cn.edu.scau.cmi.chenyuanying.client;

import cn.edu.scau.cmi.chenyuanying.orm.hibernate.HibernateSessionFactory;
import javafx.application.Application;
import javafx.event.EventHandler;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
import javafx.stage.WindowEvent;

public class HibernateClient extends Application {
	public static void main(String[] args) {
		launch();
	}

	@Override
	public void start(Stage primaryStage) throws Exception {
		Parent root = FXMLLoader.load(getClass().getResource("/cn/edu/scau/cmi/chenyuanying/orm/hibernate/HibernateStage.fxml"));
		primaryStage.setTitle("Hibernate");
		primaryStage.setScene(new Scene(root));
		primaryStage.setOnCloseRequest(new EventHandler<WindowEvent>() {
			@Override
			public void handle(WindowEvent event) {
				HibernateSessionFactory.getSessionFactory().close();
			}			
		});
		primaryStage.show();
		
		
	}
}
